home *** CD-ROM | disk | FTP | other *** search
- package symantec.itools.db.pro;
-
- import java.util.Hashtable;
- import java.util.Properties;
- import symjava.sql.SQLException;
-
- public class Request extends Properties {
- public static final String UNIQUE = new String("0");
- public static final String UNIQUE_MODIFIED = new String("1");
- public static final String ALL = new String("2");
- public static final String REC_POS_FIRST = new String("1");
- public static final String REC_POS_NEW = new String("2");
- public static final String REC_POS_NOPOS = new String("3");
- private ConnectionInfo _conn;
- private String _sql;
- protected Session _sess;
-
- public Request(Session sess, ConnectionInfo conn) {
- this._sess = sess;
- this._conn = conn;
- }
-
- public void setRequestProperties(Properties requestProps) {
- this.transferProperties(requestProps);
- }
-
- public Properties getRequestProperties() {
- return this;
- }
-
- public void setSQL(String sql) {
- this._sql = sql;
- }
-
- public String getSQL() {
- return this._sql;
- }
-
- public void setConnectionInfo(ConnectionInfo conn) {
- this._conn = conn;
- }
-
- public ConnectionInfo getConnectionInfo() {
- return this._conn;
- }
-
- public RelationView executeRequest() throws SQLException {
- return this._sess.createView(this._conn, this._sql, this);
- }
-
- protected int getOptConc() {
- String value = ((Properties)this).getProperty("optConc", UNIQUE_MODIFIED);
- Integer i = Integer.valueOf(value);
- return i;
- }
-
- protected String getInitialRecordPos() {
- return ((Properties)this).getProperty("recPosition", REC_POS_NOPOS);
- }
-
- private void transferProperties(Properties newProps) {
- ((Hashtable)this).put("optConc", newProps.getProperty("optConc", UNIQUE_MODIFIED));
- ((Hashtable)this).put("recPosition", newProps.getProperty("recPosition", REC_POS_NOPOS));
- }
-
- public void setOptimisticConcurrency(String setting) {
- if (setting.equals("All")) {
- ((Hashtable)this).put("optConc", ALL);
- } else if (setting.equals("Unique")) {
- ((Hashtable)this).put("optConc", UNIQUE);
- } else {
- ((Hashtable)this).put("optConc", UNIQUE_MODIFIED);
- }
- }
-
- public void setInitialRecordPosition(String setting) {
- if (setting.equals("First")) {
- ((Hashtable)this).put("recPosition", REC_POS_FIRST);
- } else if (setting.equals("New")) {
- ((Hashtable)this).put("recPosition", REC_POS_NEW);
- } else {
- ((Hashtable)this).put("recPosition", REC_POS_NOPOS);
- }
- }
-
- Session getSession() {
- return this._sess;
- }
- }
-